<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>产品出入库管理</title>
</head>
<body>
<style>
    .by{
        padding: 10px;
        text-align: center;
    }
</style>
<script>
    $(function () {
        $("tboby tr").addClass("datagrid-row");
        $("#iodg").datagrid({
            onDblClickRow:function(index,row){
                var JSONObj = new Object();
                var ioid = row.ioDispatherId;
                var type = row.iotype;
                JSONObj.ioid = ioid;
                JSONObj.iotype = type;
                //发送ajax请求获取数据
                $.ajax({
                    url:'getDetailsData',
                    type:'post',
                    dataType:'json',
                    data:JSONObj,
                    success:function (data) {
                        $("#ioProdg").datagrid('loadData',data);
                    },
                    error:function (error) {
                        console.log(error);
                    }
                });
            },
            onLoadSuccess:function (data) {
                $("a[name='details']").linkbutton({
                    width:30,iconCls:'icon-my_detail',plain:true
                });
                $("a[name='delete-one-pro']").linkbutton({
                    onClick: function () {
                        var rowId = $(this).attr("id").substring(4);
                        $.messager.confirm("继续删除提示", "确定要删除选定的产品吗？", function (a) {
                            if (a) {
                                $.post("IOlog-del", {rowsId: rowId}, function (r) {
                                    if (r.success) {
                                        $.messager.alert("SUCCESS", "删除成功！", "info");
                                        $("#iodg").datagrid({
                                            url:'allIOlogPaged',
                                            method:'post'
                                        });
                                        $("#iodg").datagrid("reload");
                                    } else {
                                        $.messager.alert("Failed", r.message, "error");
                                    }
                                });
                            }
                        });
                    },
                    width:30,iconCls:'icon-my_delete',plain:true
                });
                $("a[name='edit']").linkbutton({
                    width:30,iconCls:'icon-my_edit',plain:true
                });

            }
        });
        $("#reloadAllIOlog").linkbutton({
            onClick:function () {
                $("#iodg").datagrid({
                    url:'allIOlogPaged',
                    method:'post'
                });
                $("#iodg").datagrid("reload");
            }
        });
        //删除选中的分类(批量删除)
        // $("#pros-del-btn").linkbutton({onClick:function (){
        //         var rowsId = "";
        //         var rows = $("#pdg").datagrid('getSelections');
        //         if(rows.length>=1){
        //             $.messager.confirm("继续删除提示","确定要删除选定的这些产品吗？",function (t) {
        //                 if(t){
        //                     for(var i =0; i<rows.length;i++){
        //                         if(i==0){
        //                             rowsId=rowsId+rows[i].pid;
        //                         }else {
        //                             rowsId=rowsId+","+rows[i].pid;
        //                         }
        //
        //                     }
        //                     $.post("pros-del",{rowsId:rowsId},function (r) {
        //                         if(r.success){
        //                             $.messager.alert("SUCCESS","删除成功！","info");
        //                             $("#pdg").datagrid({
        //                                 url:'allProPaged',
        //                                 method:'post'
        //                             });
        //                             $("#pdg").datagrid("reload");
        //                         }else{
        //                             $.messager.alert("Failed",r.message,"error");
        //                         }
        //                     });
        //                 }
        //             });
        //
        //         }else{
        //             $.messager.alert("错误信息","未选中行！！！",'warning');
        //         }
        //     }});
    });
    function formatT(value,row,index){
        if(value!=null){
            if(value==1){
                return '<b style="color:green;">出库</b>';
            }
            if(value==2){
                return '<b style="color:blue;">入库</b>';
            }
            if(value==3){
                return '<b style="color:red;">退货入库</b>';
            }
            if(value==4){
                return'<b style="color:yellow;">退货出库</b>';
            }
        }else{
            return value;
        }
    }
    function formatImg(value,row,index){
        // return '<div id="box">'+
        //        '<div class="small_pic">'+
        //        '<span class="slider"></span>'+
        //        '<a href="to-proImgZoomIn?value='+value+'\" target="_blank"><img  title=\"点击查看高清图\" alt=\"图片暂时无法显示\"  src=\"'+'productionsphotosZoomOut\\'+value+'\"/></a>'+
        //        '</div>'+
        //        '<div class="big_pic">'+
        //        '<img class="big_pic_img" src=\"'+'productionsphotosZoomOut\\'+value+'\"  width=\"150\" height=\"150\"/>'+
        //        '</div>'+
        //        '</div>';
        return '<a href="to-proImgZoomIn?value='+value+'\" target="_blank"><img  title=\"点击查看高清图\" alt=\"图片暂时无法显示\"  src=\"'+'productionsphotosZoomOut\\'+value+'\"/></a>';
    }
    // function format(value,row,index){
    //     var str='<a id = \"'+"ioShow"+row.pid+'\" name="details" href="#" onclick="createDialogHut(\'detilsPro'+row.pid+'\',\'产品详情\',\'to-form-pro-details\','+row.pid+')" class="easyui-linkbutton edit-btn"></a>'+
    //         '<a id =\"'+"ioDel"+row.pid+'\" name="delete-one-IOlog" href="#"  class="easyui-linkbutton edit-btn"></a>'+
    //         '<a id = \"'+"ioUpdate"+row.pid+'\" name="edit" href="#" onclick="createDialogHut(\'editPro'+row.pid+'\',\'修改产品信息\',\'to-form-pro-update\','+row.pid+')" class="easyui-linkbutton edit-btn"></a>';
    //     return str;
    //
    // }

</script>
<div class="easyui-layout"  data-options="fit:true, border:false">
    <div data-options="region:'north', border:false" style="padding:5px;">
        <div class="easyui-layout" data-options="fit:true,border:false">
            <div data-options="region:'north',border:false">
                <!--工具栏-->
                <div id="tools-io">
                    <%--<a href="#" id="IOlog-del-btn" class="easyui-linkbutton" data-options="iconCls:'icon-my_delete',plain:true">批量删除</a>--%>
                    <a  id="reloadAllIOlog" class="easyui-linkbutton" data-options="iconCls:'icon-my_search'">查询所有</a>

                    <input id="io-Search" class="easyui-searchbox" style="width: 45%;" data-options="searcher:function(value,name){
           $('#iodg').datagrid({
            url:'queryByioidOriotitleMh',
            method:'post',
            queryParams:{q:value,b:name}
            });
            $('#io-Search').searchbox('clear');
            $('#iodg').datagrid('reload');
           },prompt:'模糊查询标题或仓库名',menu:'#IOlist'"/>
                    <div id="IOlist" class="easyui-menu" data-options="minWidth:100">
                        <div name="i1">所有内容</div>
                        <div name="i2">出库流水</div>
                        <div name="i3">入库流水</div>
                    </div>
                   <!--  <a href="#" onclick="createDialog('hlQueryIOlog','高级查询','to-form-IO-highLevel')" class="easyui-linkbutton"  data-options="border:true" style="width:60px;height:30px;">高级查询</a> -->
                </div>
            </div>
            <div data-options="region:'center',border:false">
                <div style="text-align: right;margin-right:5%;">
                    <a href="#" onclick="createDialog('newIO','新建出入库','to-form-IO-add')" class="easyui-linkbutton" data-options="iconCls:'icon-mini_add2',border:true">新建出入库</a>
                </div>
            </div>
            <div data-options="region:'south',border:false">
                <table id="iodg" class="easyui-datagrid table-chance" data-options="fit:true,title:'已出库/已入库单信息',border:false,striped:true,minHeight:240,fitColumns:true,
   autoRowHeight:true,nowrap:false,pagination:true,
pageList:[5,10,15,20],pageSize:5,url:'allIOlogPaged',method:'post',scrollbarSize:0">
                    <thead>
                    <tr class="datagrid-header-row">
                        <th data-options="field:'code',width:5,align:'center',checkbox:true">编码</th>
                        <th data-options="field:'ioid',width:10,align:'center'">流水ID</th>
                        <th data-options="field:'iotitle',width:20,align:'center'">标题</th>
                        <th data-options="field:'iotype',width:20,align:'center'" formatter="formatT">类型</th>
                        <th data-options="field:'ioDate',width:30,align:'center'">执行日期</th>
                        <th data-options="field:'ioDispatherId',align:'center',hidden:true">采购或订单id</th>
                        <th data-options="field:'handmanId',align:'center',hidden:true">经手人id</th>
                        <th data-options="field:'handman',width:20,align:'center'">经手人</th>
                        <th data-options="field:'iorname',width:20,align:'center'">仓库名称</th>
                        <%--<th data-options="field:'handman',width:5,align:'center',hidden:true">出库量</th>--%>
                        <%--<th data-options="field:'handman',width:5,align:'center',hidden:true">入库量</th>--%>
                        <%--<th data-options="field:'psname',width:15,align:'center'">采购状态</th>--%>
                        <th data-options="field:'clientname',width:20,align:'center'">客户/供应商</th>
                        <%--<th data-options="field:'manager',width:20,align:'center'" formatter="format">操作</th>--%>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div data-options="region:'center',title:'对应出入库单产品详情', border:false" style="padding:5px;">
        <table id="ioProdg" class="easyui-datagrid table-chance" data-options="fit:true,border:false,striped:true,fitColumns:true,
   autoRowHeight:true,nowrap:false,pagination:true,
pageList:[5,10,15,20],pageSize:10,scrollbarSize:0">
            <thead>
            <tr class="datagrid-header-row">
                <th data-options="field:'code',width:5,align:'center',checkbox:true">编码</th>
                <th data-options="field:'iodId',width:10,align:'center'">明细ID</th>
                <th data-options="field:'iodpName',width:20,align:'center'">产品名称</th>
                <th data-options="field:'iodpImg',width:20,align:'center'" formatter="formatImg">产品图片</th>
                <th data-options="field:'ioacount',width:20,align:'center'">出/入库量</th>
            </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
</div>
</body>
</html>
